import {TOKEN_NAME_KEY, TOKEN_VALUE_KEY} from "@/constant/constant.ts";
import axios from "axios";

const tokenName = localStorage.getItem(TOKEN_NAME_KEY) ?? "";
const tokenValue = localStorage.getItem(TOKEN_VALUE_KEY) ?? "";
axios.defaults.withCredentials = false; // 允许携带凭证信息，如 cookies
axios.defaults.headers[tokenName] = tokenValue;

// 创建axios实例
 const UploadService = axios.create({
    // axios中请求配置有baseURL选项，表示请求URL公共部分
    baseURL: import.meta.env.VITE_HTTP_BASE_URL,
    // 超时
    timeout: 1000000
});

 export default UploadService;
